<template>
	<view>
	
		<view class="box">
			
			<view class="top" v-for="(item,index) in list" :key="index" @click="changes(item)">
				<view class="" style="text-align: center;padding-top: 12rpx;">
					<image :src="item.image" mode="widthFix" style="width: 230rpx;"></image>
				</view>
				<view class="namex" style="width: 330rpx;padding: 0 22rpx;font-size: 24rpx;text-align: center;">
					{{item.name}}
				</view>
				<view class="back" >
					<view class="old" style="font-size: 24rpx;color: #666666;">
						原价：<text style="text-decoration:line-through">￥{{item.ori_price}}</text>
					</view>
					
						
						<view class="bosx">
							<view  style="font-size: 14rpx;">
							限时优惠
							</view>
							<view class="d_f a_i_c j_c_c" style="width: 82rpx;">
								<view class="new" >
									￥
								</view>
								<view class="new1" >
								{{item.sale_price.split('.')[0] }}.
								</view>
								<view class="new2" >
								{{item.sale_price.split('.')[1] }}
								</view>
							</view>
						</view>
					
				
					
					
				</view>
				
			</view>
		</view>
	</view>
</template>

<script>

	import {
		wxLogin,
		getMpUrl,
		getGoodsList
	} from '../../api/index.js'
	export default {
		data() {
			return {
				a:'',
				list:[
				
				]
			}
		},
		components: {

		},
		methods: {
		changes(item){
		console.log(item.detail)
		uni.setStorageSync('detail', item.detail)
		uni.setStorageSync('code', item.code)
			uni.setStorageSync('images', item.images)
			uni.setStorageSync('name', item.name)
			uni.navigateTo({
				url:'/pages/del/del?price='+item.sale_price+'&oldprice='+item.ori_price
			})
		}
		},
		onLoad(option) {
			
			
			if(option.a){
				uni.setStorageSync('a', option.a)
				this.a=option.a
				getMpUrl({
					a:option.a,env:54
				}).then((res)=>{
					
				})
			}
			
			if(!uni.getStorageSync('openidH5')){
				uni.login({
					provider: 'weixin', //使用微信登录
					success: function(loginRes) {
						console.log(loginRes.code);
							
						wxLogin({
							code:loginRes.code,
							type:3,
							proid:0
						}).then((res)=>{
							console.log(res)
							uni.setStorageSync('openidH5', res.data.openidH5)
						})
				
					}
				});
			}
			getGoodsList({}).then((res)=>{
				console.log(res)
				this.list=res.data
				for(var i in this.list){
					this.list[i].sale_price=this.list[i].sale_price.toString()
				}
			})
	

		},
		watch: {

		},
		computed: {

		}
	}
</script>

<style scoped lang='scss'>
	.old{
		margin-top: 12rpx;
		width: 140rpx;
	}
	.namex{
		
		  display: -webkit-box;
		  -webkit-line-clamp: 1;
		  -webkit-box-orient: vertical;
		  overflow: hidden;
		  text-overflow: ellipsis;
		  
		
		  
		
		
	}
.box{

	position: relative;
	display: flex;
	flex-wrap: wrap; 


}
.top{
	background-color: #FFFFFF;
	width: 330rpx;
	
	margin-left: 30rpx;
	margin-top: 12rpx;
	
}
.back{
display: flex;
width: 100%;
background-image: url('../../static/bg.png');
background-size: 100% 100%;
height: 83rpx;

padding-top: 26rpx;
padding-left: 9rpx;
margin-top: 16rpx;

}
.new{

	

	font-weight: 800;
	font-size: 18rpx;
	color: #634409;
}
.new1{

	

	font-weight: 800;
	font-size: 26rpx;
	color: #634409;
}
.new2{

	

	font-weight: 800;
	font-size: 18rpx;
	color: #634409;
}
.bosx{
	align-items: center;
	margin-top: -20rpx;
	margin-left: 18rpx;
	text-align: center;
	
}

</style>
